package com.minhua.jijiehao2.mainframe.account.accountFragment.impl

import com.minhua.jijiehao2.bean.AllAccountBean
import com.minhua.jijiehao2.bean.BaseBean
import com.minhua.jijiehao2.http.*
import com.minhua.jijiehao2.mainframe.account.accountFragment.imp.IAccountModel

class AccountModel : IAccountModel {
    override fun getAllAccount(map: ParamsMap, callBack: CallBack<AllAccountBean>) {
        HttpController<AllAccountBean>().doHttp(
                ApiClient.getInstance().api.getAllAccount(map.toRequestBody()),
                object : BaseSubscriber<AllAccountBean>() {
                    override fun dealData(t: BaseBean<AllAccountBean>) {
                        callBack.onSuccess(t)
                    }
                },
                false
        )
    }

    override fun deleteAccount(map: ParamsMap, callBack: CallBack<Any>) {
        HttpController<Any>().doHttp(
                ApiClient.getInstance().api.deleteAccount(map.toRequestBody()),
                object : BaseSubscriber<Any>() {
                    override fun dealData(t: BaseBean<Any>) {
                        super.dealData(t)
                        callBack.onSuccess(t)
                    }
                }
        )
    }

    override fun repayAccount(map: ParamsMap, callBack: CallBack<Any>) {
        HttpController<Any>().doHttp(
                ApiClient.getInstance().api.repayAccount(map.toRequestBody()),
                object : BaseSubscriber<Any>() {
                    override fun dealData(t: BaseBean<Any>) {
                        super.dealData(t)
                        callBack.onSuccess(t)
                    }
                }
        )
    }

}